<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link href="../css/H-ui.min.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" type="text/css" href="../css/H-ui.css"/>
    <link rel="stylesheet" type="text/css" href="../css/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../js/jqueryPagination/jquery.pagination.css"/>
    <title>订单管理</title>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i>
    首页 <span class="c-gray en">&gt;</span>
    订单管理 <span class="c-gray en">&gt;</span>
    订单查询列表
</nav>
<div class="page-container statusFlowVoList">
    <div class="cl pd-5 bg-1 bk-gray">
        <span class="r">共有数据：<strong class="total"></strong> 条</span>
        <input type="hidden" id="orderDetail" dataId="" dataCustName="" detailId="" />
        <input type="hidden" id="pageNum" data="data-pageNum"/>
    </div>
    <div>
        <div class="condition-row clearfix pd-5">
            <div class="fl paLeft">
                <input type="text" name="name" id="name" placeholder="请输入客户姓名" class="input-text"
                       onblur="replaceSpace(this.value,this.id)">
            </div>
            <div class="fl paLeft">
                <input type="text" name="distributorName" id="distributorName" placeholder="请输入配送商姓名" class="input-text"
                       onblur="replaceSpace(this.value,this.id)">
            </div>
            <!--<div class="fl paLeft">-->
                <!--<input type="text" name="productName" id="productName" placeholder="请输入产品名称" class="input-text"-->
                       <!--onblur="replaceSpace(this.value,this.id)">-->
            <!--</div>-->
            <div class="fl paLeft">
                    <input type="text" class="input-text Wdate" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd'})"  value="" placeholder="请输入下单时间" id="createTime" name="createTime">
            </div>
            <div class="fl paLeft">
                <select name="status" id="status" style="width: 100px;">
                    <option value="">订单状态</option>
                    <option value="-10">已关闭</option>
                    <option value="10">待付款</option>
                    <option value="20" selected>待接单</option>
                    <option value="30">配送中</option>
                    <option value="40">已完成</option>
                </select>
            </div>
            <div class="btn btn-success radius searchBtn" onclick="getData(0)">搜索</div>
        </div>
    </div>
    <table class="table table-border table-bordered table-hover table-bg table-sort ">
        <thead>
        <tr>
            <th scope="col" colspan="20">订单查询列表</th>
        </tr>
        <tr class="text-c">
            <th>订单ID</th>
            <th>客户姓名</th>
            <th>直接推荐人客户姓名</th>
            <th>间接推荐人客户姓名</th>
            <th>起点推荐人客户姓名</th>
            <th>联系人</th>
            <th>手机号</th>
            <th>省/市/区县/街道/地址</th>
            <th>订单金额</th>
            <th>配送商姓名</th>
            <th>订单状态</th>
            <th>下单时间</th>
            <th>微信支付流水号</th>
            <!--<th>产品名称</th>-->
            <th>操作</th>
        </tr>
        </thead>
        <tbody class="tableCon">

        </tbody>
    </table>
    <div id="PaginationListTop1" class="page">
        <div id="PaginationList1" class="page-wrap" style="">
            <div id="Pagination2"></div>
        </div>
    </div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="../js/layer/2.4/layer.js"></script>
<script type="text/javascript" src="../js/H-ui.js"></script>
<script type="text/javascript" src="../js/H-ui.min.js"></script>
<script type="text/javascript" src="../js/postJson.js"></script>
<script type="text/javascript" src="../js/jqueryPagination/jquery.pagination.min.js"></script>
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/js/root.js"></script>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">

    function getData(pageNo) {
        var pageNum = pageNo == 0 ? 1 : pageNo;
        var pageSize = 10;
        var name = $("#name").val();
        var distributorName = $("#distributorName").val();
        var productName = $("#productName").val();
        var createTime = $("#createTime").val();
        var status = $("#status").find("option:selected").val();
        var jsonObj = {
            "name": name,
            "distributorName": distributorName,
            "productName": productName,
            "createTime": createTime,
            "status": status,
            "pageNo": pageNum,
            "pageSize": pageSize
        }
        var jsonData = JSON.stringify(jsonObj)
        // console.log(jsonData)
        var url =  "/tradeOrderController/getTradeOrderVoList";
        $.ajax({
            url: url,
            contentType: "application/json",
            data: jsonData,
            type: "post",
            async: false,
            dataType: 'json',
            success: function (msg) {
                // console.log(JSON.stringify(msg))
                $(".tableCon ").empty();
                var htmlString = '';
                $(".total").text(msg.data.total)
                if (msg.data.list != null) {
                    $.each(msg.data.list, function (i, n) {
                        htmlString += '<tr class="text-c">'
                        htmlString += '<td>' + ifNull(n.id) + '</td>'
                        htmlString += '<td>' + ifNull(n.name) + '</td>'
                        htmlString += '<td>' + ifNull(n.bbName) + '</td>'
                        htmlString += '<td>' + ifNull(n.yyName) + '</td>'
                        htmlString += '<td>' + ifNull(n.zzName) + '</td>'
                        htmlString += '<td>' + ifNull(n.contact) + '</td>'
                        htmlString += '<td>' + ifNull(n.mobile) + '</td>'
                        htmlString += '<td>' + ifNull(n.province) + "/" + ifNull(n.city) + "/" + ifNull(n.county) + "/" + ifNull(n.street) + "/" + ifNull(n.address) +'</td>'
                        htmlString += '<td>' + ifNull(n.amount) + '</td>'
                        htmlString += '<td>' + ifNull(n.distributorName) + '</td>'
                        htmlString += '<td>' + tradeOrderStatus(n.status) + '</td>'
                        htmlString += '<td>' + TimeHours(n.createTime) + '</td>'
                        htmlString += '<td>' + ifNull(n.wxPayOutTradeNo) + '</td>'
                        // htmlString += '<td>' + ifNull(n.productName) + '</td>'
                        htmlString += '<td class="text-c">'
                        htmlString += '<a class="btn btn-danger radius m_lr10" onclick="tradeOrderDetail(' + "\'订单详情\'" + ',' + "\'toTradeOrderDetail\'" + ',' + n.id + ',' + "\'"+n.name+"\'" + ',' + 800 + ',' + 550 + ')">订单详情</a>'
                        htmlString += '</td>'
                        htmlString += '</tr>'
                    })
                } else {
                    htmlString += '<tr class="text-c"><td colspan="20">没有找到匹配的记录</td></tr>'
                }
                $(".tableCon ").append(htmlString);

                var newPageNo = pageNo == 0 ? 1 : pageNo
                //翻页
                $("#Pagination2").pagination({
                    currentPage: newPageNo,
                    totalData: msg.data.total,
                    totalPage: msg.data.pages,
                    isShow: true,
                    count: 4,
                    showData: pageSize,
                    homePageText: "首页",
                    endPageText: "尾页",
                    prevPageText: "上一页",
                    nextPageText: "下一页",
                    callback: getData
                });
                $("input[placeholder='页码']").css({
                    "border": "solid 1px #c5b7b7"
                })
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                var XmlStatus = XMLHttpRequest.status
                if (XmlStatus == 401) {
                    alert(XmlError.error401)
                    parent.window.location.href = "login"
                }
                if (XmlStatus == 403) {
                    alert(XmlError.error403)
                }
            }
        });
    }
    getData(0)


    //订单状态
    function tradeOrderStatus(data) {
        if (data == -10) {
            return '已关闭'
        } else if (data == 10) {
            return '待付款'
        } else if (data == 20) {
            return '待接单'
        } else if (data == 30) {
            return '配送中'
        } else if (data == 40) {
            return '已完成'
        }else{
            "-"
        }
    }

    /*基本信息*/
    function tradeOrderDetail(title, url, id, name,w, h) {
        $("#orderDetail").attr({
            "dataId": id,
            "dataCustName": name,
            "detailId": null,
        })
        layer_show(title,url, w, h);
    }


    //键盘按下Enter键搜索
    $(document).keyup(function (e) {
        if (e.keyCode == 13) {
            $(".searchBtn").click()
        }
    })

</script>
</body>
</html>